// 封装一个自定义hook，让我们可以快速调用 全局的提示框组件
import { useDispatch } from "react-redux"
import { Dispatch } from "redux"
import { SHOW_TOAST } from "@/store/ActionType"
export function useToast() {
    const dispatch = useDispatch<Dispatch<IToastAction>>()
    return (message: string, type: AlertColor = "success") => {
        dispatch({
            type: SHOW_TOAST,
            payload: {
                show: true,
                message,
                type
            }
        })
    }
}